home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Controls
/
Visual Basic Controls.iso
/
vbcontrol
/
dragonfl
/
aaplayr1.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-05-27
|
21KB
|
726 lines
unit Aaplayr1;
{ Delphi 2 Demo program for flic panel component }
{ 27th May 1998 }
{ ------------------------------------------------------------------------- }
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls, Spin, Menus, Gauges,
AAPlayr2, MMSystem, FlicPanel;
const
SYSTEM_PATH_LENGTH = 144;
USER_PATH_LENGTH = 255;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
Open1: TMenuItem;
Exit1: TMenuItem;
OpenDialog1: TOpenDialog;
Gauge1: TGauge;
Bevel3: TBevel;
OpenDialog2: TOpenDialog;
LoopPlay: TMenuItem;
N3: TMenuItem;
Exitprogram1: TMenuItem;
AnimGroupBox: TGroupBox;
Label3: TLabel;
WidthValue: TEdit;
HeightValue: TEdit;
FramesLabel: TLabel;
FramesValue: TEdit;
SpeedValue: TEdit;
Anim2GroupBox: TGroupBox;
Label5: TLabel;
SpeedEdit: TSpinEdit;
XEdit: TEdit;
YEdit: TEdit;
Label6: TLabel;
FramePanel: TPanel;
LoopPanel: TPanel;
Label4: TLabel;
NotifyGroupBox: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
CheckBox10: TCheckBox;
OpenDialog3: TOpenDialog;
NotifyCancelButton: TButton;
Sound1: TMenuItem;
Associate1: TMenuItem;
ButtonPanel: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure SpeedEditChange(Sender: TObject);
procedure OpenFlicFile(AFilename: string);
procedure Open1Click(Sender: TObject);
procedure XEditChange(Sender: TObject);
procedure YEditChange(Sender: TObject);
procedure Associate1Click(Sender: TObject);
procedure NotifyCheckBoxClick(Sender: TObject);
procedure LoopPlayClick(Sender: TObject);
procedure NotifyCancelButtonClick(Sender: TObject);
procedure Exitprogram1Click(Sender: TObject);
procedure Help2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
private
{ Private declarations }
SoundLoops: integer;
SoundPtrs: array[1..10] of PChar;
SoundFlags: array[1..10] of Boolean;
public
{ Public declarations }
protected
{ Protected declarations }
procedure WndProc(var Message: TMessage); override;
end;
var
Form1: TForm1;
{ The following two are needed because trying to access the message
numbers in the flic panel component in a form's WndProc
causes a GPF when WndProc is called during form (and hence
flic panel) creation: }
NotifyMessageNum: word;
StopMessageNum: word;
FrameMessageNum: word;
RedimMessageNum: word;
{ ------------------------------------------------------------------------- }
implementation
{$R *.DFM}
{ ------------------------------------------------------------------------- }
procedure TForm1.FormCreate(Sender: TObject);
var
tempp: integer;
begin
for tempp := 1 to 10 do
begin
GetMem(SoundPtrs[tempp], SYSTEM_PATH_LENGTH);
end;
for tempp := 1 to 10 do
begin
SoundFlags[tempp] := FALSE;
end;
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.FormDestroy(Sender: TObject);
var
tempp: integer;
begin
for tempp := 1 to 10 do
begin
FreeMem(SoundPtrs[tempp], SYSTEM_PATH_LENGTH);
end;
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.Open1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
OpenFlicFile(OpenDialog1.Filename);
Open1.enabled := FALSE;
end;
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.OpenFlicFile(AFilename: string);
var
tempstr: string[12];
begin
form2.Enabled := TRUE;
form2.visible := TRUE;
{ If these are in Form1's constructor, causes GPF }
NotifyMessageNum := form2.flicpanel1.NotifyMessageNum;
StopMessageNum := form2.flicpanel1.StopMessageNum;
FrameMessageNum := form2.flicpanel1.FrameMessageNum;
RedimMessageNum := form2.flicpanel1.RedimMessageNum;
with form2.flicpanel1 do
begin
FileName := AFileName;
CallbackHandle := Form1.handle;
// Stretchable := TRUE;
Open;
str(FlicWidth, tempstr);
WidthValue.Text := tempstr;
str(FlicHeight, tempstr);
HeightValue.Text := tempstr;
str(FlicFrames, tempstr);
FramesValue.Text := tempstr;
str(DesignSpeed, tempstr);
SpeedValue.Text := tempstr;
SpeedEdit.Value := Speed;
SpeedEdit.Enabled := TRUE;
XEdit.Enabled := TRUE;
YEdit.Enabled := TRUE;
Gauge1.progress := 1;
FramePanel.Caption := '1';
LoopPanel.Caption := '1';
Gauge1.maxvalue := FlicFrames;
Associate1.enabled := TRUE;
LoopPlay.Enabled := TRUE; { turn on play looping menu }
X := 4; { to let the panel border show }
Y := 4;
PlayLoops := 0; { play animation once }
PlayFrames := FlicFrames;
end;
// form2.flicpanel1.width := form2.flicpanel1.flicwidth * 2;
// form2.flicpanel1.paint;
form2.Width := form2.flicpanel1.Width + 16;
form2.Height := form2.flicpanel1.Height + 33;
form2.Caption := ExtractFilename(AFilename);
CheckBox1.Enabled := TRUE;
CheckBox2.Enabled := TRUE;
CheckBox3.Enabled := TRUE;
CheckBox4.Enabled := TRUE;
CheckBox5.Enabled := TRUE;
CheckBox6.Enabled := TRUE;
CheckBox7.Enabled := TRUE;
CheckBox8.Enabled := TRUE;
CheckBox9.Enabled := TRUE;
CheckBox10.Enabled := TRUE;
Associate1.Enabled := TRUE; { turn on sound association button }
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.SpeedEditChange(Sender: TObject);
begin
form2.flicpanel1.Speed := SpeedEdit.Value;
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.Associate1Click(Sender: TObject);
begin
if OpenDialog2.Execute then
begin
form2.flicpanel1.Sound := OpenDialog2.Filename;
Caption := ExtractFilename(form2.flicpanel1.Filename) + ' + ' +
ExtractFilename(OpenDialog2.Filename);
end;
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.XEditChange(Sender: TObject);
var
temp, temp2: integer;
begin
if Sender = XEdit then
begin
val(XEdit.Text, temp2, temp);
if (temp = 0) and (temp2 > -1) then
begin
form2.flicpanel1.X := temp2;
end;
end;
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.YEditChange(Sender: TObject);
var
temp, temp2: integer;
begin
if Sender = YEdit then
begin
val(YEdit.Text, temp2, temp);
if (temp = 0) and (temp2 > -1) then
begin
form2.flicpanel1.Y := temp2;
end;
end;
end;
{ ------------------------------------------------------------------------- }
procedure TForm1.NotifyCheckBoxClick(Sender: TObject);
var
temp, temp2: integer;
begin
val(TCheckBox(Sender).Caption, temp2, tem